package cate.common.table.d;

import cate.common.table.common.ParamSheet;
import cp.solution.util.str.Str;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.HashSet;
import java.util.Set;

@NoteClass("公会战")
public final class GDGuildWar {

    @NoteField("最强公会赛季奖励")
    public static String TOP_GUILD_SEASON_RWD_STR;
    @NoteField("最强玩家赛季奖励")
    public static String TOP_ROLE_SEASON_RWD_STR;
    @NoteField("膜拜奖励")
    public static String ADMIRE_RWD_STR;
    @NoteField("公会战单服最大公会数量")
    public static int GUILD_PICK_MAX;
    @NoteField("赛季持续天数")
    public static int SEASON_DAY;
    @NoteField("每周开放的天数")
    public static Set<Integer> DAY_OF_WEEK = new HashSet<>();
    @NoteField("基础积分")
    public static final int INIT_POINT = 1000;
    @NoteField("胜利积分")
    public static int WIN_BASE_POINT;
    @NoteField("积分差系数")
    public static double POINT_DIFFER_COEFF;
    @NoteField("积分差最大值")
    public static int POINT_DIFFER_MAX;
    @NoteField("失败扣除积分")
    public static int FAIL_POINT;
    @NoteField("公会参与等级")
    public static int GUILD_LEVEL_MIN;
    @NoteField("活跃成员最低数量")
    public static int ACTIVE_MEMBER_MIN;
    @NoteField(value = "活跃玩家判定天数",detail = "最多多少天不上线还能被判断为活跃")
    public static int OFFLINE_DAY_MAX;
    @NoteField("公会战最少开服天数限制")
    public static int OPEN_DAY_MIN;
    @NoteField("据点最大数量")
    public static int PT_MAX_NUM;

    @NoteField("据点的最大星星数量")
    public static final int STAR_MAX = 3;







    @NoteClass("公会战-阶段")
    public static final class Period {
        @NoteField("未开始或已结束")
        public static final byte NULL = 0;

        @NoteField(value = "报名阶段", detail = "游戏服开始往跨服发送本服参赛的公会信息")
        public static final byte SIGN_UP = 1;

        @NoteField(value = "匹配阶段", detail = "跨服组广播匹配结果，游戏服之间互相拉取playSide")
        public static final byte MATCH = 2;

        @NoteField(value = "战斗阶段", detail = "允许玩家进行挑战")
        public static final byte FIGHT = 3;

        @NoteField(value = "领奖阶段", detail = "结算奖励")
        public static final byte SETTLE_RWD = 4;

        public static byte getNextPeriod(byte p) {
            byte result = (byte) (p + 1);
            if (result > SETTLE_RWD || result < NULL) {
                return NULL;
            }
            return result;
        }

        public static String getDes(byte p) {
            switch (p) {
                case SIGN_UP:
                    return "报名";
                case MATCH:
                    return "匹配";
                case FIGHT:
                    return "战斗";
                case SETTLE_RWD:
                    return "领奖";
                default:
                    return "未开始或已结束";
            }
        }
    }

    /** 读取excel中配置的参数 */
    public static void initialize(ParamSheet param) {
        TOP_GUILD_SEASON_RWD_STR = GDParamTool.getString(param, 10100, "");
        TOP_ROLE_SEASON_RWD_STR = GDParamTool.getString(param, 10101, "");
        ADMIRE_RWD_STR = GDParamTool.getString(param, 10102, "");
        GUILD_PICK_MAX = GDParamTool.getInt(param, 10103, 20);
        SEASON_DAY = GDParamTool.getInt(param, 10104, 14);
        String str = GDParamTool.getString(param, 10105, "1#3#6");
        if (StringUtils.isNotBlank(str)) {
            DAY_OF_WEEK.clear();
            DAY_OF_WEEK.addAll(Str.strArr2intList(str.split("#")));
        }
        WIN_BASE_POINT = GDParamTool.getInt(param, 10106, 60);
        POINT_DIFFER_COEFF = GDParamTool.getDouble(param, 10107, 1500) / GD.W_10000_0;
        POINT_DIFFER_MAX = GDParamTool.getInt(param, 10108, 25);
        FAIL_POINT = GDParamTool.getInt(param, 10109, 25);
        GUILD_LEVEL_MIN = GDParamTool.getInt(param, 10110, 3);
        ACTIVE_MEMBER_MIN = GDParamTool.getInt(param, 10111, 5);
        OPEN_DAY_MIN = GDParamTool.getInt(param, 10112, 8);
        PT_MAX_NUM = GDParamTool.getInt(param, 10113, 10);
        OFFLINE_DAY_MAX = GDParamTool.getInt(param, 10114, 3);
    }
}
